﻿using System.Collections;
using System.Collections.Generic;
using USClientKernel.Template;
using UnityEngine;
using Common.Utils;
using Common.Utils.Helper;
using USClientKernel;


namespace Game
{
    // 游戏入口
    public class GameEntry : UGlobalSingleton<GameEntry>
    {
        private static IClientKernel m_clientKernel;

        void Awake()
        {
            m_clientKernel = ClientKernel.Instance;
            UnityHelper.AddChildToParent(GlobalTransform, transform);
            GameTest.TestAll();
        }

        void Start()
        {
            m_clientKernel.Start();
            GlobalGameObject.AddComponent<DebugInfo>();
        }

        void Update()
        {
#if UNITY_EDITOR
            if (null == m_clientKernel)
                m_clientKernel = ClientKernel.Instance;
#endif
            m_clientKernel.Update();
        }

        private void FixedUpdate()
        {
            if (null != m_clientKernel)
                m_clientKernel.FixedUpdate();
        }

        public void OnDestroy()
        {
            if (null != m_clientKernel)
                m_clientKernel.Exit();
        }
    }
}
